package br.com.cong.view.ui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.io.Serializable;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

public class StatusBar extends JPanel implements Serializable {

	private static final long serialVersionUID = 1L;
	private TempoMensagem msgThead;
	private JPanel jPanel1;
	private JLabel lblMsg1;
	private JLabel lblMsg2;
	private JLabel lblMsg3;
	private JLabel lblMsg4;
	private JLabel lblMsg5;
	private JPanel pnl0;
	private JPanel pnl1;
	private JPanel pnl2;
	private JPanel pnl3;
	private JPanel pnl4;

	public void setPanelObjetc(int posicao, Object obj) {
	}

	public void setMensagem(String msg) {
		if ((this.msgThead != null) && (this.msgThead.isAlive())) {
			this.msgThead.interrupt();
		}
		this.msgThead = new TempoMensagem(this.lblMsg1);
		this.lblMsg1.setText(" " + msg);
		this.msgThead.start();
	}

	public void setMensagem4(String msg) {
		this.lblMsg5.setText(" " + msg);
	}

	public void setMensagem3(String msg) {
		this.lblMsg4.setText(" " + msg);
	}

	public void setMensagem2(String msg) {
		this.lblMsg3.setText(" " + msg);
	}

	public void setMensagem1(String msg) {
		this.lblMsg2.setText(" " + msg);
	}

	public void setMensagem0(String msg) {
		this.lblMsg1.setText(" " + msg);
	}

	public JPanel getPanel0() {
		return this.pnl0;
	}

	public JPanel getPanel1() {
		return this.pnl1;
	}

	public JPanel getPanel2() {
		return this.pnl2;
	}

	public JPanel getPanel3() {
		return this.pnl3;
	}

	public JPanel getPanel4() {
		return this.pnl4;
	}

	public StatusBar() {
		initComponents();
		this.msgThead = null;
	}

	private void initComponents() {
		this.jPanel1 = new JPanel();
		this.pnl0 = new JPanel();
		this.lblMsg1 = new JLabel();
		this.pnl4 = new JPanel();
		this.lblMsg5 = new JLabel();
		this.pnl1 = new JPanel();
		this.lblMsg2 = new JLabel();
		this.pnl2 = new JPanel();
		this.lblMsg3 = new JLabel();
		this.pnl3 = new JPanel();
		this.lblMsg4 = new JLabel();

		setLayout(new BorderLayout());

		setMaximumSize(new Dimension(2147483647, 20));
		setMinimumSize(new Dimension(364, 20));
		setPreferredSize(new Dimension(364, 20));
		this.jPanel1.setLayout(new GridBagLayout());

		this.pnl0.setLayout(new BorderLayout());

		this.pnl0.setBorder(new BevelBorder(1));
		this.pnl0.setMaximumSize(new Dimension(2147483647, 20));
		this.pnl0.setMinimumSize(new Dimension(14, 20));
		this.pnl0.setPreferredSize(new Dimension(14, 20));
		this.lblMsg1.setFont(new Font("Dialog", 0, 11));
		this.pnl0.add(this.lblMsg1, "West");

		GridBagConstraints gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.fill = 1;
		gridBagConstraints.anchor = 12;
		gridBagConstraints.weightx = 1.0D;
		gridBagConstraints.weighty = 1.0D;
		this.jPanel1.add(this.pnl0, gridBagConstraints);

		this.pnl4.setLayout(new BorderLayout());

		this.pnl4.setBorder(new BevelBorder(1));
		this.pnl4.setMaximumSize(new Dimension(150, 14));
		this.pnl4.setMinimumSize(new Dimension(150, 14));
		this.pnl4.setPreferredSize(new Dimension(150, 14));
		this.lblMsg5.setFont(new Font("Dialog", 0, 11));
		this.pnl4.add(this.lblMsg5, "West");

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 4;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.fill = 1;
		gridBagConstraints.anchor = 18;
		gridBagConstraints.weighty = 1.0D;
		this.jPanel1.add(this.pnl4, gridBagConstraints);

		this.pnl1.setLayout(new BorderLayout());

		this.pnl1.setBorder(new BevelBorder(1));
		this.pnl1.setMaximumSize(new Dimension(25, 14));
		this.pnl1.setMinimumSize(new Dimension(25, 14));
		this.pnl1.setPreferredSize(new Dimension(25, 14));
		this.lblMsg2.setFont(new Font("Dialog", 0, 11));
		this.pnl1.add(this.lblMsg2, "West");

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 1;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.fill = 1;
		gridBagConstraints.weighty = 1.0D;
		this.jPanel1.add(this.pnl1, gridBagConstraints);

		this.pnl2.setLayout(new BorderLayout());

		this.pnl2.setBorder(new BevelBorder(1));
		this.pnl2.setMaximumSize(new Dimension(25, 14));
		this.pnl2.setMinimumSize(new Dimension(25, 14));
		this.pnl2.setPreferredSize(new Dimension(25, 14));
		this.lblMsg3.setFont(new Font("Dialog", 0, 11));
		this.pnl2.add(this.lblMsg3, "West");

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.fill = 1;
		gridBagConstraints.weighty = 1.0D;
		this.jPanel1.add(this.pnl2, gridBagConstraints);

		this.pnl3.setLayout(new BorderLayout());

		this.pnl3.setBorder(new BevelBorder(1));
		this.pnl3.setMaximumSize(new Dimension(250, 14));
		this.pnl3.setMinimumSize(new Dimension(250, 14));
		this.pnl3.setPreferredSize(new Dimension(250, 14));
		this.lblMsg4.setFont(new Font("Dialog", 0, 11));
		this.pnl3.add(this.lblMsg4, "West");

		gridBagConstraints = new GridBagConstraints();
		gridBagConstraints.gridx = 3;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.fill = 1;
		gridBagConstraints.anchor = 18;
		gridBagConstraints.weighty = 1.0D;
		this.jPanel1.add(this.pnl3, gridBagConstraints);

		add(this.jPanel1, "Center");
	}

	class TempoMensagem extends Thread {

		JLabel msgLabel;

		public TempoMensagem(JLabel msgContainer) {
			this.msgLabel = msgContainer;
		}

		public void run() {
			try {
				Thread.sleep(3000L);
				this.msgLabel.setText("");
			} catch (InterruptedException localInterruptedException) {
			}
		}
	}
}